package com.small.nacos.api.naming;

import com.small.nacos.api.config.ConfigService;
import com.small.nacos.api.exception.NacosException;

import java.lang.reflect.Constructor;
import java.util.Properties;

public class NamingFactory {
    //创建服务配置类
    public static NamingService createNamingService(Properties properties) throws NacosException {
        try {
            Class<?> aClass = Class.forName("com.small.nacos.client.naming.NacosNamingService");
            Constructor<?> constructor = aClass.getConstructor(Properties.class);
            NamingService namingService = (NamingService)constructor.newInstance(properties);
            return namingService;
        }catch (Throwable e){
            throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
        }

    }
}
